package engine.newUi
{
	import engine.control.MiniLoadingBar;
	import engine.data.ModelLocator;
	import engine.net.datatype.WString;
	import engine.net.event.CustomMsgEvent;
	import engine.net.messages.CustomToClientFlag;
	import engine.net.messages.CustomToServerFlag;
	import engine.net.mgr.SystemSender;
	
	import flash.display.DisplayObject;
	import flash.display.MovieClip;
	import flash.events.Event;
	import flash.events.MouseEvent;
	import flash.events.ProgressEvent;
	import flash.events.TimerEvent;
	import flash.text.TextField;
	import flash.utils.Timer;
	
	import newx.StageInfo;
	import newx.com.config.StaticIni;
	import newx.com.control.NxClip;
	import newx.com.control.button.NxButton;
	import newx.com.control.text.NxLabel;
	import newx.com.control.window.NxWindowEvent;
	import newx.com.loader.SwfLoader;

	/**
	 * 帮派战结果逻辑 
	 * @author liuel
	 * 
	 */	
	public class FactionWinInfroLogic
	{
		// 1 白 2 绿 3 蓝 4 紫 5 橙 6 暗金 7 ？ 8 红
		private const COLOR_TABLE	:Array	=	["","#ffffff'>","#1eff00'>","#0070dd'>","#a335ee'>","#ff8000'>","#e5cc80'>","#ffff00'>","#ff0000'>"];
		private static var _self			:FactionWinInfroLogic;
		private var _ui					:FactionWinInfroUI;
		private var _model					:ModelLocator;
		//保存左方所有帮派容器
		private var _leftFactionVector		:Vector.<FactionInfoVo>;
		//保存右方所有帮派的容器
		private var _rightFactionVector	:Vector.<FactionInfoVo>;
		//保存左方按钮中帮派数据
		private var _leftBtnVector			:Vector.<LookInfoVo>;
		//保存右方按钮中帮派数据
		private var _rightBtnVector		:Vector.<LookInfoVo>;;
		
		//存放左方帮派的晋级路线
		private var _leftMcArr				:Array = [];
		//存放右方帮派的晋级路线
		private var _rightMcArr			:Array = [];
		private var _leftArr				:Array = [];
		private var _rightArr				:Array = [];
		//当前赛场  1： 8强  2 ：4强  3 ：半决赛  1：总决赛
		private var _currIndex				:int=1;
		private var _state					:int=1;
		
		private var _CanShowBtn			:int;
		/**战斗开始状态**/
		public const ATTACK_START	:int =2;
		/**八强赛1*/		
		public const EIGHT_COMPEPT	:int =1;
		/**四强赛2**/
		public const FOUR_COMPEPT	:int =2;
		/**半决赛3**/
		public const HALF_COMPEPT	:int =3;
		/**总决赛4**/
		public const CHIEF_COMPEPT	:int =4;
		/**结束5**/
		public const ACTION_COMPEPT:int =5;
		/**左右双方的数据个数(2条/帮派 共8帮派)**/
		public const TOTAL_INFO	:int =16;
		
		private var _date		:Date;
		private var _time		:Timer;
		
		private var _leftLabelArr:Array =[];
		private var _rightLabelArr:Array=[];
		private var _winLabel:TextField;
		
		private var _selfFaction:String="";
		
		private var _allFactionInfo:Array=[];
		public static function getInstance():FactionWinInfroLogic
		{
			if(_self == null)
			{
				_self = new FactionWinInfroLogic();
			}
			return _self;
		}
		public function FactionWinInfroLogic()
		{
		}
		public function  Init():void
		{
			_date		= new Date();
			_time		= new Timer(1000);
			
			_leftFactionVector	= new Vector.<FactionInfoVo>();
			_rightFactionVector = new Vector.<FactionInfoVo>();
			
			_leftBtnVector		= new Vector.<LookInfoVo>();
			_rightBtnVector 	= new Vector.<LookInfoVo>();
			_ui 		= FactionWinInfroUI.getInstance();
			_model		= ModelLocator.getInstance();
			_model.addEventListener(String(CustomToClientFlag.SERVER_CUSTOMMSG_GUILD_FIGHT_TREE),getFactionInfo);
			_model.addEventListener(String(CustomToClientFlag.SERVER_CUSTOMMSG_GUILDFIGHT_STATUS),getState);
			_model.addEventListener(String(CustomToClientFlag.SERVER_CUSTOMMSG_SEND_IS_DOUBLE_GUILD),getBtnState);
			_leftMcArr = [_ui.mc17["mc_0"],_ui.mc17["mc_1"],_ui.mc17["mc_2"],_ui.mc17["mc_3"],_ui.mc17["mc_4"],_ui.mc17["mc_5"],_ui.mc17["mc_6"],_ui.mc17["mc_7"]];
			_rightMcArr	= [_ui.mc17["mc_8"],_ui.mc17["mc_9"],_ui.mc17["mc_10"],_ui.mc17["mc_11"],_ui.mc17["mc_12"],_ui.mc17["mc_13"],_ui.mc17["mc_14"],_ui.mc17["mc_15"]];
			
			_leftLabelArr = [_ui.mc17["txt_0"],_ui.mc17["txt_1"],_ui.mc17["txt_2"],_ui.mc17["txt_3"],_ui.mc17["txt_4"],_ui.mc17["txt_5"],_ui.mc17["txt_6"],_ui.mc17["txt_7"]];
			_rightLabelArr= [_ui.mc17["txt_8"],_ui.mc17["txt_9"],_ui.mc17["txt_10"],_ui.mc17["txt_11"],_ui.mc17["txt_12"],_ui.mc17["txt_13"],_ui.mc17["txt_14"],_ui.mc17["txt_15"]];
			_winLabel =_ui.mc17["txt_16"];
		}
		public function	BeforeShow():void
		{
			initBar();
			addEvent();
		}
		private function initBar():void
		{
			if(_ui.picMC.source ==null)
			{
				MiniLoadingBar.getInstance().show("加载中....");
			    SwfLoader.StartLoad(StageInfo.swfResPath + "faction.swf",null,compeleFunc,[onLoading]);
			}
			
		}
		private function compeleFunc(val:DisplayObject, pList:Array = null):void
		{
			var nx:NxClip = _ui.picMC as NxClip;
			nx.source = val;
		}
		private function onLoading(e:Event):void
		{

			var pe:ProgressEvent=e as ProgressEvent;
			if(pe)
				MiniLoadingBar.getInstance().progress=pe.bytesLoaded/pe.bytesTotal;
		}
		public function	AfterHide():void
		{
			_leftFactionVector	= new Vector.<FactionInfoVo>();
			_rightFactionVector = new Vector.<FactionInfoVo>();
			_leftBtnVector		= new Vector.<LookInfoVo>();
			_rightBtnVector 	= new Vector.<LookInfoVo>();
			removeEvent();
		}
		private function addEvent():void
		{
			_time.addEventListener(TimerEvent.TIMER,onPlayer);
			_ui.windowBG.addEventListener(NxWindowEvent.WINDOW_CLOSE,			onClose);
			_ui.addEventListener(MouseEvent.CLICK,								onClickBtn);
			_ui.joinBtn.addEventListener(MouseEvent.CLICK,						onJoin);
		}
		private function removeEvent():void
		{
			_time.removeEventListener(TimerEvent.TIMER,onPlayer);
			_ui.windowBG.removeEventListener(NxWindowEvent.WINDOW_CLOSE,		onClose);
			_ui.removeEventListener(MouseEvent.CLICK,							onClickBtn);
			_ui.joinBtn.removeEventListener(MouseEvent.CLICK,					onJoin);
		}
		private function onJoin(e:MouseEvent):void
		{
			SystemSender.getInstance().CustomMsg(CustomToServerFlag.CLIENT_CUSTOMMSG_REQUEST_GOTO_FIGHT_SCENE,1);
			
		}
		private function getFactionInfo(e:CustomMsgEvent=null):void
		{
			_allFactionInfo=[];
			_selfFaction =  _model.scene.Role.getPlayerGuild();
			var factionArr :Array	=e.pList;
			 _state		= factionArr.shift(); // 状态 /准备  2开始 3休息 4分组
			
			_currIndex	= factionArr.shift();  //当前的赛场  18强 2 4强  3 半决赛  4 总结赛 0结束
			
		 	_CanShowBtn= factionArr.shift(); //能否显示按钮 0不显示 1显示
			setUI(_CanShowBtn,_currIndex);
			SaveFactionInfo(factionArr);
			_allFactionInfo=factionArr;
			if(_ui.created == false)
			{
				_ui.showOrHide();
			}
		}
//		/**
//		 *自己的帮派是否被淘汰 
//		 * @param arr
//		 * @return 
//		 * 
//		 */		
//		private function getHaveSelfFaction():void
//		{
//			_ui.selfStateLabel.visible=false;
//			var lIndex:int=-1
//			for(var i:String in _leftFactionVector)
//			{
//				if(_leftFactionVector[i].name==_selfFaction)
//				{
//					lIndex=int(i);
//				}
//			}
//			if(_state==1)
//			{
//				if(lIndex !=-1&&(_leftFactionVector[lIndex].index+1)<_currIndex)
//				{
//					_ui.selfStateLabel.visible=true;
//					_ui.selfStateLabel.htmlText =StaticIni.getSwfLangStr("UIString_1000317");
//					return;
//				}
//			}
//			else
//			{
//				if(lIndex !=-1&&(_leftFactionVector[lIndex].index+1+1)<=_currIndex)
//				{
//					_ui.selfStateLabel.visible=true;
//					_ui.selfStateLabel.htmlText =StaticIni.getSwfLangStr("UIString_1000317");
//					return;
//				}
//			}
//			
//			var rIndex:int=-1;
//			for(var j:String in _rightFactionVector)
//			{
//				if(_rightFactionVector[i].name==_selfFaction)
//				{
//					rIndex=int(i);
//				}
//			}
//			if(_state>1)
//			{
//				if(rIndex !=-1&&(_leftFactionVector[rIndex].index+1)<=_currIndex)
//				{
//					_ui.selfStateLabel.visible=true;
//					_ui.selfStateLabel.htmlText =StaticIni.getSwfLangStr("UIString_1000317");
//					return;
//				}
//				
//			}
//			else
//			{
//				if(rIndex !=-1&&(_leftFactionVector[rIndex].index+1+1)<_currIndex)
//				{
//					_ui.selfStateLabel.visible=true;
//					_ui.selfStateLabel.htmlText =StaticIni.getSwfLangStr("UIString_1000317");
//					return;
//				}
//				
//			}
//			
//
//		}
		private function getState(e:CustomMsgEvent):void
		{
			_state = e.pList[0];
			_date.time =e.pList[1]*1000;
			_currIndex =e.pList[2];
			_CanShowBtn =e.pList[3];
			if(_date.time>0)
			{
				_time.start();
			}
			setUI(_CanShowBtn,_currIndex);
			//设置晋级路线
			setMcPath(_leftFactionVector,2);
			setMcPath(_rightFactionVector,2);
			showChampion();
//			SystemSender.getInstance().CustomMsg(CustomToServerFlag.CLIENT_CUSTOMMSG_REQUEST_GUILDFIGHT_TREE);
		}
		private function getBtnState(e:CustomMsgEvent):void
		{
			_leftArr =[];
			_rightArr=[];
			var BtnInfo:Array =[];
			BtnInfo=e.pList;
			for(var i:int=0; i<BtnInfo.length;i++)
			{
				if(i<4)
				{
					_leftArr.push(BtnInfo[i]);
				}
				else if(i>3 && i<8)
				{
					_rightArr.push(BtnInfo[i]);	
				}
				else if(i>7 && i<10)
				{
					_leftArr.push(BtnInfo[i]);
				}
				else if(i>9 && i<12)
				{
					_rightArr.push(BtnInfo[i]);	
				}
				else if(i==12)
				{
					_leftArr.push(BtnInfo[i]);
				}
				else if(i == 13)
				{
					_rightArr.push(BtnInfo[i]);	
				}
				else if(i == 14)
				{
				}
			}
			updateBten(_leftArr);
			updateBten(_rightArr);
			
		}
		private function setFactionName(vector:Vector.<FactionInfoVo>,type:int):void
		{
			var arr:Array=[];
			if(type == 1) //左
			{
				arr =_leftLabelArr;
			}
			else //右
			{
				arr =_rightLabelArr;
			}
			var strName:String="";
			for(var i:String in vector)
			{
				if(int(i)==8)
				{
					return;
				}
				if(_selfFaction == vector[int(i)].name)
				{
					strName = link_color(vector[int(i)].name,7);
				}
				else
				{
					strName = link_color(vector[int(i)].name,1);
				}
				(arr[i] as TextField).htmlText = strName;
			}
		}
		private function setUI(CanShowBtn:int,index:int):void
		{
			if(CanShowBtn==0)
			{
				_ui.joinBtn.visible = false;
			}
			else if(CanShowBtn == 1)
			{
				_ui.joinBtn.visible = true;
			}
			setTounamentMC(index);
			if(_state ==0)
			{
				var str:String=StaticIni.getSwfLangStr("GuildUIStr_44");
				_ui.timelabel.htmlText = str+"";
			}


		}
		/**
		 *设置赛场   
		 * @param val 1 8强赛 2 4强赛 3 半决赛 4 总决赛
		 * 
		 */		
		private function setTounamentMC(val:int):void
		{
			var index:int=1;
			switch(val)
			{
				case EIGHT_COMPEPT:
					index = 1;
					break;
				case FOUR_COMPEPT:
					index = 2;
					break;
				case HALF_COMPEPT:
					index = 3
					break;
				case CHIEF_COMPEPT:
					index = 4;
					break;
				case ACTION_COMPEPT:
					index = 4;
					break;
			}
			_ui.mc18.gotoAndStop(index);
		}
		private function onClose(e:NxWindowEvent):void
		{
			_ui.hide();
		}
		/**
		 *更新按钮显示 
		 * @param vector
		 * @param type   1左 2 右
		 * 
		 */		
		private function updateBten(vector:Array):void
		{
			var str:String;
			if(vector == _leftArr) //左
			{
				str ="leftBtn";
			}
			else
			{
				str ="rightBtn";
			}
			for(var i:String in vector)
			{
				if(int(i) ==7)
				{
					return
				}

				if(vector[i] == 1)
				{
					((_ui[str+(int(i)+1)]) as NxButton).visible =true;
				}
				else
				{
					((_ui[str+(int(i)+1)]) as NxButton).visible =false;
				}
			}
		}
			
		/**
		 * 获取冠军帮派 
		 * @return 
		 * 
		 */		
		private function getChampionFaction():FactionInfoVo
		{

			for(var i:int=0;i<_leftFactionVector.length; i++)
			{
				if(_leftFactionVector[i].index>=CHIEF_COMPEPT)
				{
					return  _leftFactionVector[i];
				}
			}
			for(var j:int=0;j<_rightFactionVector.length; j++)
			{
				if(_rightFactionVector[j].index>=CHIEF_COMPEPT)
				{
					return _rightFactionVector[j];
				}
			}
		
			return new FactionInfoVo("",0);
		}
		private function SaveFactionInfo(arr:Array):void
		{
			for(var i:int=0;i<arr.length;i+=2)
			{
				if(i<TOTAL_INFO)
				{
					_leftFactionVector.push(new FactionInfoVo(arr[i],arr[i+1]));
					
				}
				else
				{
					_rightFactionVector.push(new FactionInfoVo(arr[i],arr[i+1]));
				}
				
			}
			//设置帮派名字
			setFactionName(_leftFactionVector,1);
			setFactionName(_rightFactionVector,2);
			//设置晋级路线
			setMcPath(_leftFactionVector,1);
			setMcPath(_rightFactionVector,1);
			//保存又有查看按钮数据
			_leftBtnVector=	SaveBtnFactionInfo(_leftFactionVector);
			_rightBtnVector=SaveBtnFactionInfo(_rightFactionVector);
			showChampion();
		}
		private function ChampionStr():String
		{
			var strName:String="";
			if(getChampionFaction().name == _selfFaction)
			{
				strName=link_color(getChampionFaction().name,7);
			}
			else
			{
				strName=link_color(getChampionFaction().name,1);
			}
			return strName;
		}
		private function showChampion():void
		{
			if(_state ==0)
			{
				
				_winLabel.htmlText = ChampionStr();
				if(getChampionFaction().name == "")
				{
					_ui.winBtn.visible = false;
					_ui.mc19.visible =false;
				}
				else
				{
					_ui.mc19.visible =true;
					_ui.winBtn.visible = true;
				}
				var str:String=StaticIni.getSwfLangStr("GuildUIStr_44");
				_ui.timelabel.htmlText = str+"";
			}
			else
			{
				_winLabel.text = "";
				_ui.winBtn.visible = false;
				_ui.mc19.visible =false;
			}
			var Champion:FactionInfoVo =getChampionFaction();
			var index:int=_leftFactionVector.indexOf(Champion);
	
			if(index == -1)
			{
				index =_rightFactionVector.indexOf(Champion);
				if(index == -1)
					return;
				if(_currIndex == CHIEF_COMPEPT) //总决赛
				{
					if(_state ==2) //战斗中
					{
						if(getChampionFaction().name == "")
						{
							return;
						}
						if((_rightMcArr[index] as MovieClip).currentFrame >= 4) //帮主的线已经到5帧
						{
							_ui.winBtn.visible = true;
							_winLabel.htmlText = ChampionStr();
							_ui.mc19.visible =true;
						}
					}
				}
			}
			else
			{
				if(_currIndex == CHIEF_COMPEPT)
				{
					if(_state ==2)
					{
						if(getChampionFaction().name == "")
						{
							return;
						}
						if((_leftMcArr[index] as MovieClip).currentFrame >= 4)
						{
							_ui.winBtn.visible = true;
							_winLabel.htmlText = ChampionStr();
							_ui.mc19.visible =true;
						}
					}
				}
			}
			
		}
		private function getIsHaveLine(vector:Vector.<LookInfoVo>,val:int):Boolean
		{
			return false;
		}
		/**
		 *保存 左右双方按钮中帮派信息 
		 * @param vector1    左方帮派容器
		 * @param vector2    存放帮派晋级数据   保存顺序为（如左方晋级 第一轮 0 1 2 3  第二轮 4 5 第三轮 6  ） 
		 * 
		 */		
		private function SaveBtnFactionInfo(vector1:Vector.<FactionInfoVo>):Vector.<LookInfoVo>
		{
			
			var oneAnnulusVector:Vector.<LookInfoVo> = new Vector.<LookInfoVo>();
			//第一轮数据  存4个胜利
			for(var i:int=0;i<vector1.length;i+=2)
			{
				var infoArr:Array = getPromotionFaction(vector1[i],vector1[i+1]);
				var vo1:FactionInfoVo = infoArr[0];
				if(oneAnnulusVector.indexOf(vo1.name)== -1)
				{
					oneAnnulusVector.push(new LookInfoVo(vo1,1,infoArr[1])); //
				}
			}
			//第二轮数据  存 2个胜利
			var twoAnnulusVetcor:Vector.<LookInfoVo> = new Vector.<LookInfoVo>();
			for(var j:int =0;j<oneAnnulusVector.length;j+=2)
			{
				var infoArr1:Array =	getPromotionFaction(oneAnnulusVector[j].vo,oneAnnulusVector[j+1].vo);
				var vo2:FactionInfoVo = infoArr1[0];
				if(twoAnnulusVetcor.indexOf(vo2.name) == -1)
				{
					twoAnnulusVetcor.push(new LookInfoVo(vo2,2,infoArr1[1])); //
				}
			}
			//第三轮数据    存一个
			var threeAnnulusVector:Vector.<LookInfoVo> = new  Vector.<LookInfoVo>();
			for(var k:int = 0; k<twoAnnulusVetcor.length;k+=2)
			{
				var infoArr2:Array = getPromotionFaction(twoAnnulusVetcor[k].vo,twoAnnulusVetcor[k+1].vo);
				var vo3:FactionInfoVo = infoArr2[0];
				if(threeAnnulusVector.indexOf(vo3.name) == -1)
				{
					threeAnnulusVector.push(new LookInfoVo(vo3,3,infoArr2[1]));
				}
			}
			//第四轮  冠军  
			var  vo4:LookInfoVo = new LookInfoVo(getChampionFaction(),4,1);
			threeAnnulusVector.push(vo4);
			return oneAnnulusVector.concat(threeAnnulusVector,twoAnnulusVetcor);
		}
		/**
		 * 设置帮派晋级入线 
		 * @param vector  帮派坐在的阵营  左：_leftFactionVector 右:_rightFactionVector
		 * @param vo      需要设置路线的帮派
		 * 
		 */		
		private function setMcPath(vector:Vector.<FactionInfoVo>,type:int):void
		{
			var mc:MovieClip;
			var vo:FactionInfoVo;
			for(var i:int=0;i<vector.length;i++)
			{
				if(i >7)
					return;
				if(vector == _leftFactionVector)
				{
					mc = _leftMcArr[i];
				}
				else
				{
					mc = _rightMcArr[i];
				}
				vo = vector[i];
				mc.gotoAndStop(vo.index+1);
				
				if(type ==1)
				{
					if(_selfFaction !="" && vector[i].name == _selfFaction)
					{
						_ui.selfStateLabel.htmlText="";
						if(mc.currentFrame<_currIndex)
						{
							_ui.selfStateLabel.htmlText =StaticIni.getSwfLangStr("UIString_1000317");
						}
					}
				}
				
				
			}
		
		}
		/**
		 * 获取晋级的帮派 
		 * @param vo1
		 * @param vo2
		 * @return 
		 * 
		 */		
		private function getPromotionFaction(vo1:FactionInfoVo,vo2:FactionInfoVo):Array
		{
			if(vo1.index - vo2.index>0)
			{
				if(vo2.name == "")
				{
					return [vo1,0];
				}
				else
				{
					return [vo1,1];
				}
				
			}
			else
			{
				if(vo1.name == "")
				{
					return [vo2,0];	
				}
				else
				{
					return [vo2,1];
				}
			}
		}
		private function onClickBtn(e:MouseEvent):void
		{
			var name:String=""; //获取胜利的帮派
			var index:int;  //轮数
			switch(e.target)
			{
				case _ui.leftBtn1:
					name 	= _leftBtnVector[0].vo.name;
					index	= _leftBtnVector[0].index;
					break;
				case _ui.leftBtn2:
					name 	= _leftBtnVector[1].vo.name;
					index	= _leftBtnVector[1].index;
					break;
				case _ui.leftBtn3:
					name 	= _leftBtnVector[2].vo.name;
					index	= _leftBtnVector[2].index;
					break;
				case _ui.leftBtn4:
					name 	= _leftBtnVector[3].vo.name;
					index	= _leftBtnVector[3].index;
					break;
				case _ui.leftBtn5:
					name 	= _leftBtnVector[4].vo.name;
					index	= _leftBtnVector[4].index;
					break;
				case _ui.leftBtn6:
					name 	= _leftBtnVector[5].vo.name;
					index	= _leftBtnVector[5].index;
					break;
				case _ui.leftBtn7:
					name 	= _leftBtnVector[6].vo.name;
					index	= _leftBtnVector[6].index;
					break;
				case _ui.rightBtn1: 
					name 	= _rightBtnVector[0].vo.name;
					index	= _rightBtnVector[0].index;
					break;
				case _ui.rightBtn2:
					name 	= _rightBtnVector[1].vo.name;
					index	= _rightBtnVector[1].index;
					break;
				case _ui.rightBtn3:
					name 	= _rightBtnVector[2].vo.name;
					index	= _rightBtnVector[2].index;
					break;
				case _ui.rightBtn4:
					name 	= _rightBtnVector[3].vo.name;
					index	= _rightBtnVector[3].index;
					break;
				case _ui.rightBtn5:
					name 	= _rightBtnVector[4].vo.name;
					index	= _rightBtnVector[4].index;
					break;
				case _ui.rightBtn6:
					name 	= _rightBtnVector[5].vo.name;
					index	= _rightBtnVector[5].index;
					break;
				case _ui.rightBtn7:
					name 	= _rightBtnVector[6].vo.name;
					index	= _rightBtnVector[6].index;
					break;
				case _ui.winBtn:
					name 	=getChampionFaction().name;
					index	= 4;
					break;
			}
			if(name == "")
				return;
			SystemSender.getInstance().CustomMsg(CustomToServerFlag.CLIENT_CUSTOMMSG_REQUEST_GUILDFIGHT_INFO,new WString(name),index);
		}
		private function onPlayer(e:TimerEvent):void
		{
			_date.time -=1000;
			var arr:Array=getTimeStr(_date);
			if(_date.time<=0)
			{
				_time.reset();
			}
			var strID:String;
			if(_state == 1)
			{
				strID = "GuildUIStr_34";
				_ui.timelabel.htmlStrByBorder = StaticIni.getSwfLangStrVar(strID,arr)+"";
			}
			else if(_state == 2)
			{
				strID = "GuildUIStr_35";
				_ui.timelabel.htmlStrByBorder = StaticIni.getSwfLangStrVar(strID,arr)+"";
			}
			else if(_state == 3)
			{
				strID = "GuildUIStr_33";
				_ui.timelabel.htmlStrByBorder = StaticIni.getSwfLangStrVar(strID,arr)+"";
			}
			else if(_state == 4)
			{
				strID = "GuildUIStr_47";
				_ui.timelabel.htmlStrByBorder = StaticIni.getSwfLangStrVar(strID,arr)+"";
			}
			else if(_state==0) //帮派战结束
			{
				var str:String=StaticIni.getSwfLangStr("GuildUIStr_44");
				_ui.timelabel.htmlText = str+"";
			}
		}
		private function link_color(str:String,color:int):String
		{
			if(color < 1 || color >8)
			{
				color	=	1;
			}
			return ("<font color ='"+COLOR_TABLE[color]+str+"</font>");
		}
		/**
		 * 转换时间 
		 * @param _date
		 * @return 
		 * 
		 */		
		private function getTimeStr(_date:Date):Array
		{
			var minutes:int  = _date.minutesUTC;
			var seconds:int  = _date.secondsUTC;
			var arr:Array   = [initTime(minutes),initTime(seconds)];
			return arr;	
		}
		/**
		 * 格式时间 
		 * @param val
		 * @return 
		 * 
		 */		
		private function initTime(val:int):String
		{
			var  va:String = val.toString();
			val>9?va:va="0"+va;
			return va;
		}
	}
}
class FactionInfoVo
{
	public var name:String; //帮派名字
	public var index:int;   //晋级阶 0:十六强强 1：八强赛 2：四强赛  3：半决赛 4：总决赛
	public function FactionInfoVo(name:String,index:int):void
	{
		this.name = name;
		this.index = index;
	}
}
//查看按钮中数据
class LookInfoVo
{
	public  var vo:FactionInfoVo;  //胜利的帮派
	public  var index:int;			//场次  1  2  3  4
	public  var rival:int;			//竞争对手名字是否为空 0空  1不空
	public  function LookInfoVo(vo:FactionInfoVo,index:int,rival:int):void
	{
		this.vo = vo;
		this.index = index;
		this.rival = rival;
	}
}